<mjml>
  {{>mjmlHeaders}}
  <mj-body background-color="#1A1B38">
    <mj-wrapper background-color="#1A1B38">
      <mj-section padding="0 0 10px 0"> </mj-section>
      <mj-section padding="0px">
        <mj-column width="100%">
          <mj-text align="center" font-size="32px" font-weight="500" padding="0px" font-size="18px" line-height="24px"
            >Metadata backup report</mj-text
          >
        </mj-column>
      </mj-section>
      <mj-section padding="0px">
        <mj-column width="80%">
          <mj-divider border-width="2px" padding-top="25px"></mj-divider>
        </mj-column>
      </mj-section>
      <mj-section padding="0px">
        <mj-column width="100%">
          <mj-text font-size="16px" font-weight="300" line-height="24px">
            <h1>Global status : {{log.status}} {{getIcon log.status}}</h1>
            <ul>
              <li><span style="font-weight: bold">Job ID</span>: {{log.jobId}}</li>
              <li><span style="font-weight: bold">Job name</span>: {{jobName}}</li>
              <li><span style="font-weight: bold">Run ID</span>: {{log.id}}</li>
              {{>reportTemporalDataMjml end=log.end start=log.start}} {{#if log.tasks.length}}
              <li>
                <span style="font-weight: bold">Successes</span>: {{#if tasksByStatus.success.length ~}}
                {{tasksByStatus.success.length}} {{~else~}} 0 {{~/if}} / {{log.tasks.length}}
              </li>
              {{/if}} {{>reportErrorMjml task=log}} {{>reportWarningsMjml task=log}}
            </ul>
          </mj-text>
        </mj-column>
      </mj-section>

      {{#each tasksByStatus}}
        <mj-section padding="0px">
          <mj-column width="100%">
            <mj-divider border-width="1px"></mj-divider>
            <mj-text font-size="16px" font-weight="300" line-height="24px">
              <h2>{{titleByStatus @key .}}</h2>
            </mj-text>
          </mj-column>
        </mj-section>
        {{#each this}}
          <mj-section padding-bottom="0px">
            <mj-column width="100%">
              <mj-text font-size="16px" font-weight="300" line-height="24px">
                <h3>{{>taskTitle task=. jobName=../../log.jobName}}</h3>
                <ul>
                  {{>taskBody task=.}} {{>reportTemporalDataMjml formatDate=../../formatDate}} {{>reportErrorMjml task=.}}
                  {{>reportWarningsMjml task=this}}
                </ul>
              </mj-text>
            </mj-column>
          </mj-section>
          {{#each this.tasks}}
            <mj-section padding="0px">
              <mj-column width="85%" border="1px solid #fffce4">
                <mj-text font-size="16px" font-weight="300" line-height="24px">
                  <span style="font-weight:bold">{{>taskTitle task=. jobName=''}}</span> {{getIcon status}}
                  <ul>
                    {{>taskBody task=.}}
                    {{>reportTemporalDataMjml formatDate=../../../formatDate}}
                    {{>reportErrorMjml task=.}}
                    {{>reportWarningsMjml task =.}}
                  </ul>
                </mj-text>
              </mj-column>
            </mj-section>
          {{/each}}
        {{/each}}
      {{/each}}

    {{>mjmlFooter}}
    </mj-wrapper>
  </mj-body>
</mjml>
